<?php

namespace App\Listeners;

use App\Events\TestQueueEvent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class TestQueueListener implements ShouldQueue
{
    //需要手动访问监听器下面队列任务的 delete 和 release 方法
    use InteractsWithQueue;

    /**
     * 任务应该发送到的队列的连接的名称
     *
     * @var string|null
     */
//    public $connection = 'sqs';

    /**
     * 任务应该发送到的队列的名称
     *
     * @var string|null
     */
    public $queue = 'listeners:test:queue';

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  TestQueueEvent  $event
     * @return void
     */
    public function handle(TestQueueEvent $event)
    {
        var_dump($event);
//        if (true) {
//            //Release the job back into the queue.
//            $this->release(30);
//            //Delete the job from the queue.
//            $this->delete();
//        }
    }
}
